 $LOAD_PATH.unshift File.join(File.dirname(__FILE__),'../..','ext_pr1/lib')
 require 'ext_pr1_v4'

TEMP_ABS_ZERO = -273
TEMP_MIN = 18
TEMP_MAX = 25


# zu_kalt ::= (temp) :: Int -> Int where (temp >= -273)
# Test {(12)=>true, (18)=>false, (17)=>true, (25)=>false, (26)=>false, 
# (-274)=>Err, (-273)=>true, ("Hallo")=>Err, (12.5)=>Err }
def zu_kalt(temp)
  check_temp(temp)
  (temp < TEMP_MIN)
end

# zu_warm ::= (temp) :: Int -> where (temp >= -273)
# Test {(26)=>true, (25)=>false, (18)=>false, (17)=>false, 
# (-273)=>false, (-274)=>Err, ("Hallo")=>Err, (12.5)=>Err}
def zu_warm(temp)
  check_temp(temp)
  (temp > TEMP_MAX)
end

# angenehm ::= (temp) :: Int -> where (temp >=-273)
# return true when (temp >=18 and temp <=25) otherwise false
# Test {(17)=>false, (18)=>true, (25}=>true, (26)=>false, 
# (-273)=>false, (-274)=>Err, ("Hallo")=>Err, (12.5)=>Err}
def angenehm(temp)
  check_temp(temp) 
  (not zu_kalt(temp) and not zu_warm(temp))
end

# unangenehm ::= (temp) :: Int -> where (temp >= -273)
# return false when (temp >=18 and temp <=25) otherwise true
# Test {(17)=>true, (18)=>false, (25}=>false, (26)=>true, 
# (-273)=>true, (-274)=>Err, ("Hallo")=>Err, (12.5)=>Err}
def unangenehm(temp)
  not angenehm(temp)
end

def check_temp(temp) 
  check_pre((temp.int? and temp >= TEMP_ABS_ZERO))
end

#def check_temp(temp) 
#  check_pre((temp.temp?))
#end

#def_class(:Temp, [:temp]){
#def temp?()   
#temp.temp?
##  temp.int? and temp >= TEMP_ABS_ZERO 
#  
#end
#}